require('./index.css')
require('page/common/top/index.js');
var _order_service = require('service/order-service.js')

var orderConfirm = {
    init : function(){
        this.loadAccountInfo();
        this.bindEvents();
        return this;
    },
    bindEvents : function(){
        $('#confirmed').on('click',function(){
            _order_service.insertOrder(
                function(res){
                    window.location.href = './order-view.html'
                },
                function(errorMsg){
                    
                }
            )
        })
    },
    loadAccountInfo : function(){
        _order_service.getOrder(
            function(res){
                console.log(res);
                $('#billToFirstName').val(res.billFirstName);
                $('#billToLastName').val(res.billLastName);
                $('#billAddress1').val(res.billAddress1);
                $('#billAddress2').val(res.billAddress2);
                $('#billCity').val(res.billCity);
                $('#billState').val(res.billState);
                $('#billZip').val(res.billZip);
                $('#billCountry').val(res.billCountry);
                $('#shipToFirstName').val(res.shipFirstName);
                $('#shipToLastName').val(res.shipLastName);
                $('#shipAddress1').val(res.shipAddress1);
                $('#shipAddress2').val(res.shipAddress2);
                $('#shipCity').val(res.shipCity);
                $('#shipState').val(res.shipState);
                $('#shipZip').val(res.shipZip);
                $('#shipCountry').val(res.shipCountry);
            },
            function(errorMsg){

            }
        )
    }
};

module.exports = orderConfirm.init()